package com.sf.leetcode.primary_alogrithm;

import java.util.Arrays;

public class finalPrices {

    public static void main(String[] args) {
        //int[] prices = {8,4,6,2,3};
        //int[] prices = {1,2,3,4,5};
        int[] prices ={10,1,1,6};
        System.out.println(Arrays.toString(finalPrices(prices)));
    }

    public  static int[] finalPrices(int[] prices){
        for (int i = 0;i < prices.length - 1 ; i++){
             for (int j = 1; j < prices.length; j++){
                 if(j > i && prices[j] <= prices[i]){
                     prices[i] = prices[i]-prices[j];
                     break;
                 }
             }
        }
        return prices;
    }

}
